class PriceTrend {
  String? id;
  num? price;
  String? priceType;
  String? priceId;
  String? origin;
  String? createDate;
  String? productCode;
  String? productName;
  String? productDesc;

  PriceTrend({
    this.id,
    this.price,
    this.priceType,
    this.priceId,
    this.origin,
    this.createDate,
    this.productCode,
    this.productName,
    this.productDesc,
  });

  PriceTrend copyWith({
    String? id,
    num? price,
    String? priceType,
    String? priceId,
  }) {
    return new PriceTrend(
      id: id ?? this.id,
      price: price ?? this.price,
      priceType: priceType ?? this.priceType,
      priceId: priceId ?? this.priceId,
    );
  }

  @override
  String toString() {
    return '''PriceTrend{
      id: $id,
      price: $price,
      priceType: $priceType,
      priceId: $priceId
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is PriceTrend &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          priceId == other.priceId);

  factory PriceTrend.fromMap(Map<String, dynamic> map) {
    return new PriceTrend(
      // product_name   product_desc    product_default_code
      id: map['id'] != false ? map['id'].toString() : '',
      price: map['price'] != false ? map['price'] : 0,
      priceType: map['price_type'] != false
          ? map['price_type'].toString() as String?
          : "",
      origin: map['origin'] != false ? map['origin'].toString() as String? : "",
      productCode: map['product_default_code'] != false ? map['product_default_code'].toString() as String? : "",
      productName: map['product_name'] != false ? map['product_name'].toString() as String? : "",
      productDesc: map['product_desc'] != false ? map['product_desc'].toString() as String? : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'price': this.price,
      'station_id': this.priceType,
      'price_id': this.priceId,
    } as Map<String, dynamic>;
  }

  // List toOdooMap() {
  //   List list = [
  //     if (this.price != null && this.price != '')
  //       ['price', '=', double.parse(this.price!)],
  //     if (this.priceType != null && this.priceType != '')
  //       ['price_type', '=', this.priceType],
  //     if (this.priceId != null && this.priceId != '')
  //       ['price_id', '=', this.priceId],
  //   ] as List;
  //   return list;
  // }
}
